﻿/**
 * ...
 * @author Sergey Mamyan
 */

package tx.utils;

class Utils {
	public static function toClassFieldString(input:String):String{
		var str:String = toClassNameString(input);
		var fc:String = str.charAt(0).toLowerCase();
		str = fc + str.substr(1);
		return str;
	}
	public static function toClassNameString(input:String):String{
		var reg:EReg = ~/[\-\.\_\s]+/g;
		var str:String = "";
		var itr:Iterator<String> = reg.split(input).iterator();
		while (itr.hasNext()) {
			var tmp:String = itr.next();
			tmp = toFirstUpperCase(tmp);
			str += tmp;
		}
		return str;
	}
	public static function toClassPackageString(input:String):String{
		var reg:EReg = ~/[\-\_\s]+/g;
		var str:String = "";
		return reg.split(input).join(".").toLowerCase();
	}
	
	public static function toFirstUpperCase(str:String):String {
		return str.charAt(0).toUpperCase() + str.substr(1);
	}
	
	public static function arraySortStandard(x:Dynamic, y:Dynamic):Int {
		if (x == y) {
			return 0;
		}else if (x > y) {
			return 1;
		}else {
			return -1;
		}
	}
}